package top.lyunk.demo.server.b.service;

import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import top.lyunk.demo.server.b.entity.Student;
import top.lyunk.demo.server.b.rpc.dubbo.dubbo.ServerBDubboAPI;

import static org.apache.dubbo.common.constants.ClusterRules.FAIL_FAST;

/**
 * <pre>
 *
 * </pre>
 *
 * @author lyk
 * @date 2022/7/29
 */
@DubboService(cluster = FAIL_FAST)
public class ServerBDubboImpl implements ServerBDubboAPI {

    @Autowired
    ServiceBService serviceBService;

    @Override
    @DubboService(cluster = FAIL_FAST)
    public String echo(String val) {
        if (true) {
            System.out.println("执行了重试");
            throw new RuntimeException("test");
        }
        return "hello " + val + ", 我是服务B";
    }

    /**
     * 添加学生
     */
    @Override
    @DubboService(cluster = FAIL_FAST, retries = 0)
    public int addStudent(Student student) {
        return serviceBService.addStudent(student);
    }
}
